import { BaseModel } from './BaseModel.js';
import { dataFiles } from '../config/database.js';

const defaultClasses = [
  {
    id: 1,
    className: '计算机科学与技术1班',
    lecturer: '张老师',
    counselor: '王导员',
    department: '计算机学院',
    classroom: '',
    createdAt: new Date().toISOString(),
    updatedAt: new Date().toISOString()
  },
  {
    id: 2,
    className: '软件工程2班',
    lecturer: '李老师',
    counselor: '刘导员',
    department: '软件学院',
    classroom: '',
    createdAt: new Date().toISOString(),
    updatedAt: new Date().toISOString()
  }
];

export class Class extends BaseModel {
  constructor() {
    super(dataFiles.classes, defaultClasses);
  }

  findByClassName(className) {
    return this.findOne({ className });
  }

  findByDepartment(department) {
    const data = this.findAll();
    return data.filter(cls => cls.department === department);
  }
}